package model;

import constant.AttributeDataType;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;

/**
 * 客户动态属性定义实体类
 */
public class AttributeDefinition {
    private int attributeId;
    private String attributeKey;
    private String displayName;
    private AttributeDataType dataType;
    private String defaultValue;
    
    // JavaFX属性，用于表格显示
    private final StringProperty attributeKeyProperty = new SimpleStringProperty();
    private final StringProperty displayNameProperty = new SimpleStringProperty();
    private final StringProperty dataTypeProperty = new SimpleStringProperty();
    private final StringProperty defaultValueProperty = new SimpleStringProperty();
    
    public AttributeDefinition() {
    }
    
    public AttributeDefinition(int attributeId, String attributeKey, String displayName, AttributeDataType dataType, String defaultValue) {
        this.attributeId = attributeId;
        this.attributeKey = attributeKey;
        this.displayName = displayName;
        this.dataType = dataType;
        this.defaultValue = defaultValue;
    }
    
    public int getAttributeId() {
        return attributeId;
    }
    
    public void setAttributeId(int attributeId) {
        this.attributeId = attributeId;
    }
    
    public String getAttributeKey() {
        return attributeKey;
    }
    
    public void setAttributeKey(String attributeKey) {
        this.attributeKey = attributeKey;
        this.attributeKeyProperty.set(attributeKey);
    }
    
    public String getDisplayName() {
        return displayName;
    }
    
    public void setDisplayName(String displayName) {
        this.displayName = displayName;
        this.displayNameProperty.set(displayName);
    }
    
    public AttributeDataType getDataType() {
        return dataType;
    }
    
    public void setDataType(AttributeDataType dataType) {
        this.dataType = dataType;
        this.dataTypeProperty.set(dataType != null ? dataType.toString() : "");
    }
    
    public String getDefaultValue() {
        return defaultValue;
    }
    
    public void setDefaultValue(String defaultValue) {
        this.defaultValue = defaultValue;
        this.defaultValueProperty.set(defaultValue);
    }
    
    // JavaFX属性的getter方法
    public StringProperty attributeKeyProperty() {
        return attributeKeyProperty;
    }
    
    public StringProperty displayNameProperty() {
        return displayNameProperty;
    }
    
    public StringProperty dataTypeProperty() {
        return dataTypeProperty;
    }
    
    public StringProperty defaultValueProperty() {
        return defaultValueProperty;
    }
    
    /**
     * 获取数据类型的描述
     * @return 数据类型的描述
     */
    public String getDataTypeDescription() {
        return dataType != null ? dataType.getDescription() : "未知类型";
    }
} 